/*
 * Miscellanea.java
 *
 * Created on March 26, 2005, 9:24 PM
 * 15, Sep 2006 converted into constructorless class
 * 06, Sep 2007 moved from package portfolio to misellanea
 */

package misellanea;

import java.awt.Dimension;
import java.lang.Object.*;
import java.io.*;
import java.text.DecimalFormat;
import java.math.*;
import java.util.Calendar;
import java.text.DateFormat;
import java.sql.Date;
import java.util.Vector;
import javax.swing.JInternalFrame;
import portfolio.*;

/**
 *
 * @author  ACA
 */
public class Miscellanea {
    /*********************************************************/
    public static void main (String  argv [])
    {
        double [][] dDataTrain = null;

        if (argv.length == 0){
            System.out.println ("usage: java Miscelanea [file]");
            return;
        }

        System.out.println (argv [0].toString ());
        int iNComp     = Integer.valueOf (argv [1]).intValue ();	// Component nuber to extract
        if (iNComp <= 0) {
            System.out.println ("Error: improper number of components requested");
            return;
        } 
        int iMaxIt = Integer.valueOf (argv [2]).intValue ();    // Max number of iterations
        if (iMaxIt <= 0) {
            System.out.println ("Error: improper number of iterations requested");
            return;
        }

        //Preprocess inputIca = new Preprocess (argv [0], iNComp, iMaxIt);
        //new IcaPreprocess ();
        String sFileName = argv [0];
        dDataTrain = readDataFile (sFileName);
        //System.out.println ("Readed Data");
        //Miscellanea.printMatrix (dDataTrain);
        
        double [] dMeanVector = getMeanVector (dDataTrain);
        System.out.println ("test: getMeanVector");
        printVector (dMeanVector);
        
        double [] dVarVector = getVarVector (dDataTrain);
        System.out.println ("\ntest: getVarVector");
        printVector (dVarVector);
        
        double [][] dCovarMtx = getVCovarMtx (dDataTrain);
        System.out.println ("\ntest getVCovarMtx");
        printMatrix (dCovarMtx);
        
        try {
        double [][] dCorrelationMtx = getCorrelationMtx (dDataTrain, dDataTrain);
        System.out.println ("\ntestCorrelation");
        printMatrix (dCorrelationMtx);
        } catch (Exception e) {}
    }    
    /*********************************************************/
    static double [][] readDataFile(String filename)
    {
        int N = 0,
            d = 0;
        BufferedReader in   = null;
        FileReader     file = null;
        int iColumn = 0;
        int iRow = 0;

        try { 
                file = new FileReader(filename);
                in   = new BufferedReader(file);
        } catch (Exception e) 
        {
                System.err.println("Error 0: " +e);
                System.exit(0);
        }

        try {
            String sLine = in.readLine ();
            for (int k = 0; k < sLine.length (); k++) {
                if (sLine.charAt(k) != ' ') { // || sLine.charAt(k) != '\t') {
                    iColumn ++;
                    for (;k < sLine.length (); k++)
                        if (sLine.charAt (k) == ' ') //|| sLine.charAt(k) != '\t') 
                            break;
                }
            }
            System.out.println ("Cols: " + iColumn);

            iRow = 1;
            while (in.readLine () != null) 
                iRow++;

            System.out.println ("Rows: " + iRow);

            in.close ();
        } catch (Exception e) 
        {
            System.err.println ("Error 1: "+ e);
            System.exit (0);
        }

        System.out.println ("Reading " + " iRow "+ iRow + " Columnas " + iColumn );

        double [][] dDataTrain = new double [iRow] [iColumn]; 
        try {
                file = new FileReader(filename);
                in   = new BufferedReader(file);
                ParseData(in, dDataTrain);
                in.close();
        } catch (Exception e) 
        {
                System.err.println ("Error 2: "+ e);
                System.exit (0);
        }

        return dDataTrain;
    }
    /*********************************************************************************************/
    /* ParseData: parse a numeric text file that represents a matrix devided in space separated. */
    /* Note: this method works for two columns only.                                             */
    /*********************************************************************************************/
    static void ParseData (BufferedReader in, double [][] Data) throws Exception
    {
        int i,
            j,
            k;
        String sLine;
        StringBuffer word = new StringBuffer();
        int iRow = Data.length;
        int iColumn = Data[0].length;

        for(i=0; i< iRow; i++) {
            sLine = in.readLine(); 
            k = 0;
            //System.out.println ("sLine "+ sLine);
            for(j=0; j < iColumn; j++) {
                word.setLength(0);

                for(; k < sLine.length (); k++)
                    if(sLine.charAt(k) != ' ') 
                        break;

                for(; k < sLine.length (); k++) {
                    char c = sLine.charAt(k);
                    if(c == ' ') 
                        break;
                    if (c == '\t')
                        break;
                    word.append (sLine.charAt(k));
                }

                Data [i][j] = Double.valueOf(word.toString()).doubleValue();
                //System.out.print (Data [i ][ j]+"\t");
            }
            //System.out.println ();
        }
    } /*end ParseData method */    
    /*************************************************/
    public static double getMean (double [] DataIn) 
    {
        int i;
        int iSize = DataIn.length;
        double meanOut = 0.0;

        if (iSize == 0)
            return 0.0;
        
        for (i = 0; i < iSize; i++) {
            meanOut = DataIn [i] + meanOut;
            //System.out.print ("["+i+"]["+j+"] "+meanOut [j]+"\t");
        }
        //System.out.println ();

        meanOut = (iSize != 0)? meanOut /iSize: 0;
        //System.out.print ("["+j+"] "+meanOut [j]+"\t");

        return meanOut;
    } /* end getMeanVector */ 
    /*************************************************************************/
    public static double [] getMeanVector (double [][] dDataIn) 
    {
        int i,
            j;
        int iRowNum = dDataIn.length ;
        int iColNum = dDataIn [0].length;
        double [] meanOut = new double [iColNum];

        for (i = 0; i < iRowNum; i++) {
            for (j = 0; j < iColNum; j++) {
                if (i == 0)
                        meanOut [j] = dDataIn [i][j];
                else
                        meanOut [j] = dDataIn [i][j] + meanOut [j];
                //System.out.print ("["+i+"]["+j+"] "+meanOut [j]+"\t");
            }
            //System.out.println ();
        }

        for (j = 0; j < iColNum; j++) {
            if (iRowNum == 0)
                    break;
            else
                 meanOut [j] = (iRowNum > 0)? meanOut [j]/iRowNum: 9999999.999;
                //System.out.print ("["+j+"] "+meanOut [j]+"\t");
        }

        return meanOut;
    } /* end getMeanVector */ 
    /********************************************************************************************/
    public static double getVar (double [] dDataIn)
    {
        int    i,
               j;
        double dTemp = 0;

        int iSize = dDataIn.length;

        double MeanIn = getMean (dDataIn);

        /********/		
        double varOut = 0;

        for (j = 0; j < iSize; j++) {
            dTemp  = dDataIn [j] - MeanIn;
            dTemp  = Math.pow (dTemp, 2);
            varOut = varOut + dTemp;
            //System.out.print ("\ti="+i+" ("+dDataIn [i][j]+"-"+MeanIn[j]+")^2="+varOut[j]+" ");
        }
        //System.out.println ();
         /**/
        varOut  =(iSize -1 > 0)? varOut /(iSize-1) : 99999.999;
        //System.out.println ("Var  ="+ varOut);
        /**/  
        return varOut;        
    }
    /********************************************************************************************/
    public static double [] getVarVector (double [][] dDataIn)
    {
        int    i,
               j;
        double dTemp = 0;

        int iRowNum = dDataIn.length ;
        int iColNum = dDataIn [0].length;

        double [] MeanIn = getMeanVector (dDataIn);

        //for (i = 0; i < iColNum; i++) System.out.println (MeanIn [i] + " ");
        /********/		
        double [] varOut = new double [dDataIn [0].length];

        for (i = 0; i < iRowNum; i++) {
            for (j = 0; j < iColNum; j++) {
                dTemp      = dDataIn [i][j] - MeanIn [j];
                dTemp      = Math.pow (dTemp, 2);
                varOut [j] = varOut [j] + dTemp;
                //System.out.print ("\ti="+i+" ("+dDataIn [i][j]+"-"+MeanIn[j]+")^2="+varOut[j]+" ");
            }
                //System.out.println ();
        }
         /**/
        for (j = 0; j < iColNum; j++) {
            varOut [j] = (iRowNum -1 > 0)? varOut [j]/(iRowNum-1): 99999.999;
            //System.out.println ("Var ["+j+"] ="+ varOut[j]);
        }
        /**/  
            return varOut;
    } /* end getVarVector */ 
    /********************************************************************************************/
    public static double [][] getVCovarMtx (double [][] dDataIn)
    {
        int    i,
                j;
        int k = 0;

        double dTemp = 0;

        int iRowNum = dDataIn.length ;
        int iColNum = dDataIn [0].length;

        double [] MeanIn = getMeanVector (dDataIn);		
        double [][] mtxOut = new double [iColNum][iColNum];

        //System.out.println ("iCol "+ iColNum+" iRowNum "+iRowNum);

        for (k = 0; k < iColNum ; k++) {
            for (i = 0; i < iColNum; i++) {
                for (j = 0; j < iRowNum; j++) {
                    dTemp      = (dDataIn [j][k] - MeanIn [k])*(dDataIn [j][i] - MeanIn [i]);

                    mtxOut [k][i] = mtxOut [k][i] + dTemp;
                    //System.out.print (" mtxOut="+mtxOut [k][i]+" ");
                }
                //System.out.println ();
            }
    /**/    System.out.println ("covar");
            for (j = 0; j < iColNum; j++) {
                if (j == k)
                    mtxOut [j][j] = (iRowNum -1 > 0)?mtxOut [j][j]/(iRowNum-1): 999999.99;
                else
                    mtxOut [k][j] = (iRowNum    > 0)?mtxOut [k][j]/(iRowNum)  : 999999.99;
                //System.out.println ("Var ["+j+"] ="+ mtxOut [k][j]);
            }
        /**/
        }
        return mtxOut;
    } /* end getVCovarMtx */
    /**************************************************************************/
    public static double [][] getCorrelationMtx (double [][] dMtxA, double [][] dMtxB) throws Exception
    {
        int iRowA = dMtxA.length;
        int iRowB = dMtxB.length;
        
        if (iRowA != iRowB) {
            new Exception ("Miscellanea::getCorrelationMtx: incompatible row length between MtxA and MtxB.");
        }
        
        int iColA = dMtxA[0].length;
        int iColB = dMtxB[0].length;
        
        double [] dMeanVectA = getMeanVector (dMtxA);
        double [] dMeanVectB = getMeanVector (dMtxB);
        
        double [] dVarVectA  = getVarVector (dMtxA);
        double [] dVarVectB  = getVarVector (dMtxB);
        
        double [][] dCorrMtx = new double [iColA][iColB];
        double dTemp = 0;
        
        for (int k = 0; k < iColB; k++) {
            for (int j = 0; j < iColA; j++) {
                for (int i = 0; i < iRowA; i++) {
                    dTemp  += (dMtxA [i][j] - dMeanVectA [j])*(dMtxB [i][k] - dMeanVectB [k]);
                    //System.out.println ("dtemp: " + dTemp);
                }
                dTemp = dTemp / iRowA;
                double dDivisor = Math.sqrt (dVarVectA [j] * dVarVectB [k]);
                
                //dCorrMtx [j][k] = dDivisor; //dTemp; //
                dCorrMtx [j][k] =(dDivisor != 0)? dTemp/dDivisor: 0.0;
                
                dTemp = 0;
            }
        }
        //printMatrix (dCorrMtx);
        return dCorrMtx;
    }
    /**************************************************************************/
    public static double getRisk (double [] dDataIn, double dReturnParam)
    {
        int    i,
               j;
        double dTemp = 0;

        int iSize = dDataIn.length;

        /********/		
        double varOut = 0;

        for (j = 0; j < iSize; j++) {
                dTemp  = dDataIn [j] - dReturnParam;
                dTemp  = Math.pow (dTemp, 2);
                varOut = varOut + dTemp;
                //System.out.print ("\ti="+i+" ("+dDataIn [i][j]+"-"+MeanIn[j]+")^2="+varOut[j]+" ");
        }
        //System.out.println ();
         /**/
        varOut  =(iSize -1 > 0)? varOut /(iSize-1) : 999999.99;
        System.out.println ("Var  ="+ varOut);
        /**/  
        return varOut;            
    }
    /********************************************************************************************/
    /* getRootMeanVect: Calculates a vector with the root mean square values of columns.        */
    /* iRowNum: Number of rows of the DataIn matrix.                                            */
    /* DataIn: Matrix to be examined in order to calculate the root mean square                 */
    /* rMeanOut: This is the place where the root mean will be placed.                          */
    /********************************************************************************************/ 
    public static double [] getRootMeanVect (int iRowNum,int iColNum, double [][] DataIn)
    {
            int i,
                j;
            double [] rMeanOut = new double [iColNum];

            if (iRowNum <=1)
                    return null;

            for (i = 0; i < iRowNum; i++) {
                for (j = 0; j < iColNum; j++) {
                    if (i == 0)
                        rMeanOut [j] = Math.pow (DataIn [i][j], 2);
                    else
                        rMeanOut [j] = Math.pow (DataIn [i][j], 2) + rMeanOut [j];
                    //System.out.print (" i["+i+"] j["+j+"] "+ rMeanOut [j]+"\t");
                }
                //System.out.println ();//" i["+i+"] j["+j+"] "+ rMeanOut [j]);
            }

            for (j = 0; j < iColNum; j++) {
                if (iRowNum == 0)
                    return null;
                else
                    rMeanOut [j] = Math.sqrt (rMeanOut [j]/(iRowNum -1)); // Can't tell why
                //System.out.print (" j["+j+"] "+rMeanOut[j]+"\t");
            }

            return rMeanOut;
    } /* end getRootVect */
    /********************************************************************/
    public static double [] getRootMeanVect (double [][] DataIn)
    {
        int iRowNum = DataIn.length ;
        int iColNum = DataIn [0].length;
        double [] rMeanOut = getRootMeanVect (iRowNum, iColNum, DataIn);

        return rMeanOut;
    } /* end getRootMeanVect */            
//    /***********************************************************************************************/
//    static public double [] getPortfolio (double [] [] mtxX)
//    {
//        int iRow = mtxX.length;
//        double dSum = 0;
//        double [] dPrtfolio = new double [iRow];
//
//        for (int i = 0; i < iRow; i++)
//                dSum = dSum + mtxX [i][0];
//
//        for (int i = 0; i < iRow; i++)
//                dPrtfolio [i] = mtxX [i][0]/dSum;
//
//        return dPrtfolio;
//    }
    /********************************************************************************************/
    public static double getReturn (double [] dDataIn, int iTermParam) throws Exception
    {
        int iSize = dDataIn.length;
        double dReturn = 0;
        
        if (iSize <= 0) {
            throw new Exception ("Miscellanea::getReturn: Invalid return vector size.");
        }
        if (iTermParam > iSize) {
            throw new Exception ("Miscellanea::getReturn:incompatible term with return vector size;");
            
        }
        System.out.println ("dReturn<<<<<<<<<<<<<");
        for (int i = iSize -1; i >= iSize - iTermParam; i--) {
            dReturn = dReturn + dDataIn [i];
        }
        
        return dReturn;
    }
    /********************************************************************************************/
	public static double [] getReturnVect (double [][] dDataIn, double dRiskFree)
	{
            int i,
                j;
            double dTemp = 0;

            int iRowNum = dDataIn.length ;
            int iColNum = dDataIn [0].length;

        /********/		
            double [] returnOut = new double [dDataIn [0].length];
            for (i = 0; i < iColNum; i++) {
                for (j = 1; j < iRowNum; j++) {
                    if (dDataIn [j-1][i] == 0)
                            continue;

                    dTemp      = (dDataIn [j][i] - dDataIn [j-1][i])/dDataIn [j-1][i];
                    returnOut [i] = returnOut [i] + dTemp;
                    //System.out.print (" mtxOut="+mtxOut [k][i]+" ");
                }
                //System.out.println ();
            }
/**/
            for (j = 0; j < iColNum; j++) {
                returnOut [j] = returnOut [j]/(iRowNum) - dRiskFree;
                System.out.println ("Var ["+j+"] ="+ returnOut [j]);
            }
/**/  
            return returnOut;
    } /* end getReturnVect */ 
        /********************************************************************************************/
         public static double [][] getTransposeMtx (double [][] dMtxIn)
         {
            int i,
                j;
            int iRowNum = dMtxIn.length;
            int iColNum = dMtxIn [0].length;
           
            double [][] dTrnsOut = new double [iColNum][iRowNum];

            //System.out.println ("Transpose in");
            for (i = 0; i < iRowNum; i++) {
                for (j = 0; j < iColNum; j++) {			
                    dTrnsOut [j][i] = dMtxIn [i][j];

                    //System.out.print ("i["+i+"] j["+j+"] "+dMtxIn [i][j]+"; "); //}dMtxOut [i][j]+"\t");
                }
                //System.out.println ();
            }

            //System.out.println ("Transpose out");

            return dTrnsOut;
         }/* end getTransposeMtx */  
        /********************************************************************************************/
	public static void printMatrix (double [][] DataIn)
	{
            int i,
                j;

            int iRowNum = DataIn .length ;
            int iColNum = DataIn [0].length;
            
            DecimalFormat dFormat = new DecimalFormat ("#0.0000");

            for (i = 0; i < iRowNum; i++) {
                for (j = 0; j < iColNum; j++) {
                    //System.out.print ("["+1+"]["+j+"] "+DataIn [i][j]+"\t");
                    System.out.print (dFormat.format (DataIn [i][j])+"\t");
                }
                System.out.println ();
            }
	
	} /* end method printMatrix */         
        /********************************************************************************************/
	public static void printVector (double [] DataIn)
	{

            int iSize = DataIn .length ;
            DecimalFormat dFormat = new DecimalFormat ("#0.0000");

            for (int j = 0; j < iSize; j++) {
                //System.out.print ("["+1+"]["+j+"] "+DataIn [i][j]+"\t");
                System.out.println (dFormat.format (DataIn [j])+"\t");
            }
            //System.out.println ();
	
	} /* end method printMatrix */
        /****************************************************************/
        public static String getNextDateRecord (String sDateParam)
        {
            Date tmpDate = java.sql.Date.valueOf (sDateParam);
            String sDateFull = DateFormat.getDateInstance(DateFormat.FULL).format(tmpDate);
            Calendar cDate   = Calendar.getInstance();
            cDate.setTime(tmpDate);
            //System.out.print (sDateFull + " ");
            if (sDateFull.startsWith ("Friday")) {
                cDate.add (Calendar.DAY_OF_WEEK, 3);
            }
            else if (sDateFull.startsWith("Saturday")) {
                cDate.add (Calendar.DAY_OF_WEEK, 2);
            }
            else {
                cDate.add (Calendar.DAY_OF_WEEK, 1);
            }
            java.util.Date nxtDate = cDate.getTime ();
            //System.out.println (DateFormat.getDateInstance (DateFormat.FULL).format (nxtDate));
            java.sql.Date nxtSqlDate = new java.sql.Date (cDate.getTimeInMillis()); 

            return nxtSqlDate.toString();
        } /* end getNextDateRecord */
        /********************************************************************/
        public static String getStringDate (Calendar dateParam)
        {
            String sDate = "\""+
                           dateParam.get (Calendar.YEAR)+ "-"+
                           (dateParam.get (Calendar.MONTH) +1)+ "-"+
                           dateParam.get (Calendar.DAY_OF_MONTH)+ "\"";

            return (sDate);
        } /* End Method getStringDate */ 
	/************************************************/
	public static int getNumberOfDaysInMonth ( Calendar c ) 
	{	
	    Calendar mathCalendar = (Calendar) c.clone();	
	    mathCalendar.set (Calendar.DAY_OF_MONTH, 1);	
	    mathCalendar.add (Calendar.MONTH, 1);	
	    mathCalendar.add (Calendar.DAY_OF_MONTH, -1);	
	    return mathCalendar.get (Calendar.DAY_OF_MONTH);
	} /* End  method getNumberOfDaysInMonth */
        /*************************************************/
        public static void showFrameInMidleScr (JInternalFrame jFrameParam, 
                                                mainScreen mainScrParam,
                                                int iWidth,
                                                int iHeight)
        {
            jFrameParam.setBounds (0, 0, iWidth, iHeight);
            Dimension mainDim = mainScrParam.getSize ();
            Dimension thisDim = jFrameParam.getSize ();
            int iXLocation = (mainDim.width / 2)  - (thisDim.width / 2);
            int iYLocation = (mainDim.height / 2) - (thisDim.height / 2);
            jFrameParam.setLocation(iXLocation, iYLocation);
            jFrameParam.show ();            
        } /* end method showFrameInMidleScr */
        /**
         *
         */
        public static boolean stringVectorContainsIgnoreCase (Vector vParam, String sCompare)
        {
            if (vParam == null)
                return false;
            int iSize = vParam.size();
            for (int iIdx = 0; iIdx < iSize; iIdx++) {
                String sTemp = vParam.get(iIdx).toString();
                if (sCompare.equalsIgnoreCase(sTemp)) {
                    return true;
                }
            }
            return false;
        }
        /**
         *
         */
        public static double [][] getWorkMatrix (double [][] dTableParam, int iTermParam)
        {
            if (dTableParam == null)
                return null;

            int iColumn = dTableParam [0].length;
            int iRow    = dTableParam.length -iTermParam;

            if (iRow <= 0 || iColumn <= 0)
                return null;

            Double DTemp;
            double [][] dMatrix = new double [iRow][iColumn];

            for (int i = 0; i < iRow; i++) {
                dMatrix [i][0] = dTableParam [i +iTermParam][0];
                //System.out.print (dMatrix [i][0] +"|");
                for (int j = 1; j < iColumn; j++) {
                    dMatrix [i][j] =  dTableParam [i][j];
                    //System.out.print (dMatrix [i][j]+" ");
                }
                //System.out.println ();
            }

            return dMatrix;		
        } /* End method portfolioMainScr::stockPanel::getWorkMatrix */  
        /**
         *
         */
        public static double [][] getTrainMatrix (double [][] dMatrixParam, int [] indexesParam)
        {
            if (dMatrixParam == null)
                return null;

            int iColumn = dMatrixParam [0].length;
            int iRow    = dMatrixParam.length;

            if (iRow <= 0 || iColumn <= 0)
                return null;

            int iRowLow  = 0;
            int iRowHigh = iRow;
            int iRowLen  = iRow;

            if (indexesParam != null) {
                if (indexesParam.length > 0) {
                        iRowLow  = indexesParam [0];
                        iRowHigh = iRowLow + indexesParam.length;
                        iRowLen  = iRowHigh - iRowLow;
                }
            }
            if (iRowLow > iRowHigh) {
                return null;
            }

            double [][] dMatrix = new double [iRowLen][iColumn];

            for (int i = iRowLow; i < iRowHigh; i++) {
                for (int j = 0; j < iColumn; j++) {
                    dMatrix [i][j] =  dMatrixParam [i +iRowLow][j];
    //                        //System.out.print (dMatrix [i][j]+" ");
                }
    //                    //System.out.println ();
                //iTmpRow++;
            }

            return dMatrix;		
        } /* End method portfolioMainScr::stockPanel::getTrainMatrix */  
        /**
         *
         */
        public static double [] getYVector (double [][] dMatrixParam) //, int [] indexesParam)
        {
            if (dMatrixParam == null)
                return null;

            int iRow    = dMatrixParam.length;

            if (iRow <= 0)
                return null;

            double [] dVector = new double [iRow];

            for (int i = 0; i < iRow; i++) {
                dVector [i] =  dMatrixParam [i][0];
                //System.out.println (dVector [i]+" ");
            }

            return dVector;		
        } /* End method portfolioMainScr::stockPanel::getYVector */               
        /**
         *
         */
        public static double [][] getXMatrix (double [][] dMatrixParam)//, int [] indexesParam)
        {
            if (dMatrixParam == null)
                return null;

            int iColumn = dMatrixParam [0].length;
            int iRow    = dMatrixParam.length; //<<<<<<<<<<<<<<<<<<< 0j0

            if (iRow <= 0 || iColumn <= 0)
                return null;

            double [][] dMatrix = new double [iRow][iColumn -1];

            for (int i = 0; i < iRow; i++) {
                for (int j = 1; j < iColumn; j++) {
                    dMatrix [i][j -1] =  dMatrixParam [i][j];
                    //System.out.print (dMatrix [i][j -1]+" ");
                }
                //System.out.println ();
            }

            return dMatrix;		
        } /* End method portfolioMainScr::stockPanel::getXMatrix */             
        /**
         *
         */
//        private double [][] getTableMatrix (JTable jTableParam, int iColumnShift)
//        {
//            int iRow = jTableParam.getRowCount();
//            int iColumn = jTableParam.getColumnCount ();
//
//            if (iRow <= 0 || iColumn <= 0)
//                return null;
//
//            Double DTemp;
//            double [][] dMatrix = new double [iRow][iColumn - iColumnShift];
//
//            for (int i = 0; i < iRow; i++) {
//                for (int j = iColumnShift; j < iColumn; j++) {
//                    DTemp = Double.valueOf(jTableParam.getValueAt (i, j).toString());
//                    dMatrix [i][j - iColumnShift] =  DTemp.doubleValue ();
//                    //System.out.print (dMatrix [i][j - iColumnShift] + " ");
//                }
//            }
//
//            return dMatrix;		
//        } /* End method portfolioMainScr::stockPanel::getTableMatrix */
        /**
         *
         */
//        private Vector getVectorTableHeader (JTable jTableParam)
//        {
//            int iCol = jTableParam.getColumnCount();
//            if (iCol <= 2)                                              // <<<<<<<<<<<<<< 0j0
//                return null;
//
//            Vector vTempTableHeader = new Vector ();
//            for (int i = 3; i < iCol; i++) {
//                vTempTableHeader.add (jTableParam.getColumnName (i)); 
//                //System.out.println (vTableHeader.get(i -3).toString());
//            }
//
//            //System.out.println (sNxtDate);                
//            return vTempTableHeader;
//        } /* end method getVectorTableHeader */

} /* end class miscellanea */
